<template>
    <div>
        <div class="bg-banner" />
        <el-container class="common-layout">
            <el-aside class="left">
                <img src="../assets/images/logo.png"
                    class="absolute left-4 top-4 h-30px rounded ring ring-stone-2 dark-ring-stone-8">
                <img src="../assets/images/login-banner.png" class="banner">
            </el-aside>
            <el-container class="right">
                <LoginFrom />
            </el-container>
        </el-container>
    </div>
</template>

<script setup>
import LoginFrom from "../components/LoginForm/index.vue"
import { login } from "../api/loginApi/login"
import { useUserStore } from '@/store/userStore'

const userStore = useUserStore()
const handleLogin = async () => {
  try {
    const res = await login({
      username: form.username,
      password: form.password
    })
    
    if (res.data) {
      // 存储用户信息
      userStore.setUserInfo(res.data)
      // 存储 token
      userStore.setToken(res.data.token)
      // 跳转到首页
      router.push('/')
      
      ElMessage.success('登录成功')
    }
  } catch (error) {
    console.error('登录失败:', error)
  }
}
</script>


<style scoped lang="scss">
* {
    box-sizing: inherit;
}

.common-layout {
    width: 80%;
    height: 80%;
    top: 50%;
    left: 50%;
    border-radius: 10px;
    box-shadow: var(--el-box-shadow);
    transform: translateX(-50%) translateY(-50%);
    position: absolute;
    display: flex;
    overflow: hidden;
    background-color: #fff;

    .left {
        position: relative;
        width: 450px;
        overflow: hidden;
        background-color: #f2f2f2;
    }

    .right {
        width: 500px;
        transition: height 0.15s ease;
    }
}

.banner {
    position: absolute;
    top: 50%;
    width: 100%;
    transform: translateY(-50%);
}

.ring-stone-2 {
    --un-ring-opacity: 1;
    --un-ring-color: rgb(231 229 228 / var(--un-ring-opacity))
        /* #e7e5e4 */
    ;
}

.ring {
    --un-ring-width: 3px;
    --un-ring-offset-shadow: var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);
    --un-ring-shadow: var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);
    box-shadow: var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);
}

.rounded {
    border-radius: 0.25rem;
}

.h-\[30px\],
.h-30px {
    height: 30px;
}

.top-4 {
    top: 1rem;
}

.left-4 {
    left: 1rem;
}

.absolute {
    position: absolute;
}

.bg-banner {
    position: fixed;
    z-index: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, var(--g-container-bg), var(--g-bg));
}
</style>